import keyboard
import win32gui


def get_window_offset():
    point = win32gui.GetCursorPos()
    hwnd = win32gui.WindowFromPoint(point)
    left, top, right, bottom = win32gui.GetWindowRect(hwnd)
    client_x, client_y = win32gui.ScreenToClient(hwnd, (left, top))
    print(point, hwnd, left, top, right, bottom)
    print(f"client_x:{client_x},client_y:{client_y}")
    pass


keyboard.add_hotkey('space', get_window_offset)

keyboard.wait("esc")
